import SvBase from "./SvBase";

export default class DragEl extends SvBase {//拖动元素

  canvas;

  init() {
  }

  style = {
    display: 'inline-block',
    position: 'absolute',
    top: '0',
    left: '0',
    zIndex: 999999,
    backgroundColor: 'red',
    width: '100px',
    height: '100px',
  }

  hide() {
    this.style.display = 'none';
  }

  show() {
    this.style.display = 'inline-block';
  }

  mousedown(e) {

    let target = e.target;
    let top = target.offsetTop;
    let left = target.offsetLeft;

    let z = (x, y) => {
      this.style.left = (left + x) + 'px';
      this.style.top = (top + y) + 'px';
    }

    this.canvas.on('drag.move', z);
  }

}
